<?
	chdir("..");
	include("common.php");

	include("siteadmin/accesscontrol.php");

	include("siteadmin/header.php");

/*
	CREATE TABLE forum (
		id smallint(6) NOT NULL auto_increment,
		name varchar(80) default NULL,
		description text,
		posts varchar(5) default NULL,
		PRIMARY KEY  (id),
		FULLTEXT KEY posts (posts)
	) TYPE=MyISAM;

	INSERT INTO forum VALUES (1, 'Official Announcements', 'We will place official announcements here.', '0');
	INSERT INTO forum VALUES (2, 'Post Paid', 'Post Paid here so members know we are paying!', '0');
	INSERT INTO forum VALUES (3, 'General Talk', 'If your topic doesn\'t belong in the other folders, place it here!', '0');
	INSERT INTO forum VALUES (4, 'Suggestions', 'Would you like to see a new feature?  If so, post that suggestion here.', '0');

	CREATE TABLE replies (
		id smallint(6) NOT NULL auto_increment,
		threadid varchar(25) default NULL,
		username varchar(25) default NULL,
		title varchar(50) default NULL,
		body text,
		timestamp int(12) NOT NULL default '0',
		PRIMARY KEY  (id)
	) TYPE=MyISAM;

	CREATE TABLE thread (
		id smallint(6) NOT NULL auto_increment,
		mb char(3) default NULL,
		username varchar(25) default NULL,
		title varchar(50) default NULL,
		replies varchar(5) default NULL,
		body text,
		timestamp int(12) NOT NULL default '0',
		lastpost_timestamp int(12) NOT NULL default '0',
		PRIMARY KEY  (id)
	) TYPE=MyISAM;
*/

	if (!$step){$step = 1;}
	switch($step){
		case "1":													// forum index
			include("siteadmin/forum/fidx.php");
			break;
		case "2":													// edit forums
			include("siteadmin/forum/editf.php");
			break;
		case "3":
			break;
		case "4":													// delete forums
			$sql = "DELETE FROM forum WHERE id=$bid";
			$qr1 = mysql_query($sql);
			$sql = "SELECT * FROM thread WHERE mb=$bid";
			$qr1 = mysql_query($sql);
			while( $row = mysql_fetch_object($qr1) ){
				$tid = $row->id;
				$sql = "DELETE FROM posts WHERE threadid=$tid";
				$qr1 = mysql_query($sql);
			}
			$sql = "DELETE FROM thread WHERE mb=$bid";
			$qr1 = mysql_query($sql);
			include("siteadmin/forum/fidx.php");		
			break;
		case "5":													// add new forum
			include("siteadmin/forum/addf.php");
			break;
		case "6":													// manage threads
			include("siteadmin/forum/tidx.php");
			break;
		default:													// user index
			include("siteadmin/forum/fidx.php");
			break;
	}

	include("siteadmin/footer.php");
?>